<template>
  <div class="agreeManage">
    <!-- 顶部搜索表单 -->
    <div class="agreeSearch">
      <el-form ref="searchForm" :model="searchForm" :inline="true" size="mini">
        <el-form-item label="时间范围："  prop="startTime">
          <el-date-picker v-model="searchForm.startTime" type="date" placeholder="选择日期时间" value-format="yyyy-MM-dd" clearable></el-date-picker>
        </el-form-item>
        <el-form-item label="---"  prop="endTime">
          <el-date-picker v-model="searchForm.endTime" type="date" placeholder="选择日期时间" value-format="yyyy-MM-dd" clearable></el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button  @click="searchBtn" type="primary" size="mini">查询</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- 上方表格 -->
    <div class="agreeTop">
      <div class="agreeTopTitle">协议</div>
      <!-- 按钮组 -->
      <div class="agreeTopBtnBox">
        <el-button plain size="mini" type="success" @click="addBtn">新增协议</el-button>
        <el-button plain size="mini" type="primary" @click="editBtn">编辑协议</el-button>
        <el-button plain size="mini" type="danger" @click="delBtn">删除协议</el-button>
      </div>
      <!-- 协议列表  表格 -->
      <el-table :data="agreeListTableData" border :height="agreeListTableHeight" :header-cell-style="{ textAlign: 'center' }" highlight-current-row @row-click="getAagreeCurrentData">
        <el-table-column type="index" align="center" label=" " width="50"></el-table-column>
        <el-table-column prop="conCltName" label="客户" show-overflow-tooltip sortable ></el-table-column>
        <el-table-column prop="conSigntm" label="签署时间" align="cneter" show-overflow-tooltip  sortable ></el-table-column>
        <el-table-column prop="conProperty" label="协议属性" show-overflow-tooltip :formatter="timeChange" sortable></el-table-column>
        <el-table-column prop="conEffsttm" label="协议起始时间" align="cneter" show-overflow-tooltip sortable ></el-table-column>
        <el-table-column prop="conEffedtm" label="协议终止时间" align="cneter" show-overflow-tooltip sortable ></el-table-column>
        <el-table-column prop="conInsertdt" label="输入时间" align="cneter" show-overflow-tooltip sortable ></el-table-column>
        <el-table-column prop="conInsertuser" label="输入员工"  show-overflow-tooltip sortable ></el-table-column>
        <el-table-column prop="conLstupddt" label="最后修改时间" align="cneter" show-overflow-tooltip sortable ></el-table-column>
        <el-table-column prop="conLstupduser" label="最后修改员工" show-overflow-tooltip sortable ></el-table-column>
        <el-table-column prop="conContent" label="内容" show-overflow-tooltip sortable ></el-table-column>
      </el-table>
      <!-- 分页 -->
      <div class="block">
        <el-pagination
          ref="pagination"
          small
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="Pagination.currentPage"
          :page-sizes="Pagination.pageSizeList"
          :page-size="Pagination.PageSize"
          :layout="Pagination.layout"
          :total="Pagination.total">
        </el-pagination>
      </div>
    </div>
    <!-- 下方表格 -->
    <div class="agreeBot">
      <div class="agreeTopTitle">协议费率</div>
      <!-- 按钮组 -->
      <div class="agreeTopBtnBox">
        <el-button plain size="mini" type="success" @click="addRateBtn">新增协议费率</el-button>
        <el-button plain size="mini" type="primary" @click="editRateBtn">编辑协议费率</el-button>
        <el-button plain size="mini" type="danger" @click="delRateBtn">删除协议费率</el-button>
      </div>
      <!-- 协议列表  表格 -->
      <el-table :data="agreeRateTableData" border :height="agreeRateTableHeight" :header-cell-style="{ textAlign: 'center' }" highlight-current-row @row-click="getRateCurrentData">
        <el-table-column type="index" align="center" label=" " width="50"></el-table-column>
        <el-table-column prop="chdCnname" label="费目名称" show-overflow-tooltip sortable ></el-table-column>
        <el-table-column prop="chpPrice" label="费率价格" show-overflow-tooltip  sortable ></el-table-column>
        <el-table-column prop="chpCurrency" label="费率币种" show-overflow-tooltip  sortable></el-table-column>
        <el-table-column prop="cchDiscount" label="折扣" show-overflow-tooltip sortable ></el-table-column>
        <el-table-column prop="chpPrice" label="协议单价" show-overflow-tooltip sortable ></el-table-column>
        <el-table-column prop="cchPayCurrency" label="支付币种" show-overflow-tooltip sortable ></el-table-column>
        <el-table-column prop="cchSettlemd" label="支付方式" :formatter="changePayStyle" show-overflow-tooltip sortable ></el-table-column>
        <el-table-column prop="cchSttm" label="起始时间" align="cneter" show-overflow-tooltip sortable ></el-table-column>
        <el-table-column prop="cchEdtm" label="终止时间" align="cneter" show-overflow-tooltip sortable ></el-table-column>
      </el-table>
    </div>

    <!-- 新增协议弹窗 -->
    <el-dialog :title="agreeDialogTitle" :visible.sync="agreeDialog" width="40%" :close-on-click-modal='false' @close="agreeDialogClose" v-el-drag-dialog>
      <div class="agreeDialogBox">
        <el-form ref="agreeDialogForm" :model="agreeDialogForm" :rules="agreeDialogRules" label-width="130px" :inline="true" size="mini">
          <el-row>
            <el-col :span="12">
              <el-form-item label="客户：" prop="cltName">
                <el-popover
                  placement="bottom"
                  width="420"
                  @show="nowShow"
                  @hide="nowHide"
                  trigger="click"
                  v-model="showPop">
                  <el-table border :data='nameList' :highlight-current-row="true" @row-click="getCurrentRow" :header-cell-style="{textAlign: 'center'}" height="300">
                    <el-table-column type="index" align="center" label=" " width="50"></el-table-column>
                    <el-table-column label="名称" prop="cltName" show-overflow-tooltip></el-table-column>
                    <el-table-column label="联系人"  prop="cltContact" show-overflow-tooltip></el-table-column>
                    <el-table-column label="联系电话"  prop="cltCtctel" show-overflow-tooltip></el-table-column>
                  </el-table>
                  <div class="el-input el-input--mini el-input--suffix" slot="reference">
                    <el-input v-model="agreeDialogForm.cltName" clearable @input="getNameData" size="mini" maxlength="20"></el-input>
                    <span class="el-input__suffix">
                      <span class="el-input__suffix-inner">
                        <i class="el-select__caret el-input__icon " :class="isShow?'el-icon-arrow-up':'el-icon-arrow-down'"></i>
                      </span>
                    </span>
                  </div>
                </el-popover>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="签署时间：" prop="conSigntm">
                <el-date-picker v-model="agreeDialogForm.conSigntm" type="datetime" placeholder="选择日期时间" value-format="yyyy-MM-dd hh:mm:ss" clearable></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="协议属性：" prop="conProperty">
                <el-select v-model="agreeDialogForm.conProperty" filterable clearable>
                  <el-option
                    v-for="item in agreeAttrList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="协议起始时间：" prop="conEffsttm">
                <el-date-picker v-model="agreeDialogForm.conEffsttm" type="datetime" placeholder="选择日期时间" value-format="yyyy-MM-dd hh:mm:ss" clearable></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="协议结束时间：" prop="conEffedtm">
                <el-date-picker v-model="agreeDialogForm.conEffedtm" type="datetime" placeholder="选择日期时间" value-format="yyyy-MM-dd hh:mm:ss" clearable></el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="22">
              <el-form-item label="内容：" prop="conContent">
                <el-input type="textarea" v-model="agreeDialogForm.conContent" clearable style="width: 280%"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div class="footBtn" style="text-align: right">
        <el-button size="mini" type="primary" @click="agreeSave">保存</el-button>
        <el-button size="mini" @click="agreeDialog = false">关闭</el-button>
      </div>
    </el-dialog>

    <!-- 新增协议费率弹窗 -->
    <el-dialog :title="agreeRateDialogTitle" :visible.sync="agreeRateDialog" width="40%" :close-on-click-modal='false' @close="agreeRateDialogClose" v-el-drag-dialog>
      <div class="agreeRateDialogBox">
        <el-form ref="agreeRateDialogForm" :model="agreeRateDialogForm" :rules="agreeRateDialogRules" label-width="130px" :inline="true" size="mini">
          <el-row>
            <el-col :span="12">
              <el-form-item label="协议：" prop="agreeMent">
                <el-select v-model="agreeRateDialogForm.agreeMent" filterable clearable disabled>
                  <el-option
                    v-for="item in moneyCates"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="费目：" prop="feeNum">
                <el-popover
                  placement="bottom"
                  width="500"
                  @show="nowShow1"
                  @hide="nowHide1"
                  trigger="click"
                  v-model="showPop1">
                  <el-table border :data='feeList' :highlight-current-row="true" @row-click="getFeeCurrentRow" :header-cell-style="{textAlign: 'center'}" height="300">
                    <el-table-column label="费目细项" prop="chpChdName" show-overflow-tooltip></el-table-column>
                    <el-table-column label="价格" align="center" prop="chpPrice" show-overflow-tooltip></el-table-column>
                    <el-table-column label="币种"  prop="chpCurrency" show-overflow-tooltip></el-table-column>
                    <el-table-column label="开始时间"  prop="chpStdt" show-overflow-tooltip></el-table-column>
                    <el-table-column label="结束时间"  prop="chpEddt" show-overflow-tooltip></el-table-column>
                  </el-table>
                  <div class="el-input el-input--mini el-input--suffix" slot="reference">
                    <el-input v-model="agreeRateDialogForm.feeNum" clearable @input="getFeeData" size="mini" maxlength="20"></el-input>
                    <span class="el-input__suffix">
                      <span class="el-input__suffix-inner">
                        <i class="el-select__caret el-input__icon " :class="isShow1?'el-icon-arrow-up':'el-icon-arrow-down'"></i>
                      </span>
                    </span>
                  </div>
                </el-popover>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="费率：" prop="feeRate">
                <el-select v-model="agreeRateDialogForm.feeRate" filterable clearable disabled>
                  <el-option
                    v-for="item in moneyCates"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="折扣：" prop="cchDiscount">
                <el-input v-model="agreeRateDialogForm.cchDiscount" clearable></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="起始时间：" prop="cchSttm">
                <el-date-picker v-model="agreeRateDialogForm.cchSttm" type="datetime" placeholder="选择日期时间" value-format="yyyy-MM-dd hh:mm:ss" clearable></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="结束时间：" prop="cchEdtm">
                <el-date-picker v-model="agreeRateDialogForm.cchEdtm" type="datetime" placeholder="选择日期时间" value-format="yyyy-MM-dd hh:mm:ss" clearable></el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="支付币种：" prop="cchPayCurrency">
                <el-select v-model="agreeRateDialogForm.cchPayCurrency" filterable clearable>
                  <el-option
                    v-for="item in moneyCates"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="支付方式：" prop="cchSettlemd">
                <el-select v-model="agreeRateDialogForm.cchSettlemd" filterable clearable>
                  <el-option
                    v-for="item in payStyles"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="22">
              <el-form-item label="备注：" prop="cchRemark">
                <el-input type="textarea" v-model="agreeRateDialogForm.cchRemark" clearable style="width: 280%"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div class="footBtn" style="text-align: right">
        <el-button size="mini" type="primary" @click="agreeRateSave">保存</el-button>
        <el-button size="mini" @click="agreeRateDialog = false">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  getCustomerSelectService,
  getAgreeListService,
  addAgreeListService,
  editAgreeListService,
  delAgreeListService,
  getFeeNumService,
  addAgreeRateService,
  getAgreeRateService,
  editAgreeRateService,
  delAgreeRateService
} from '@/request/api'
import paginationMixin from '@/mixins/pagination'
export default {
  name: 'router.agreeManage',
  mixins: [paginationMixin],
  data() {
    return {
      searchForm: {
        startTime: '', // 开始时间
        endTime: '', // 结束时间
      },
      agreeCurrentData: '', // 协议列表  表格  当前行数据
      agreeListTableData: [], // 协议列表  表格  数据
      agreeListTableHeight: 420, // 协议列表  表格  数据
      agreeRateCurrentData: '', // 协议费率  表格  当前行数据
      agreeRateTableData: [], // 协议费率  表格  数据
      agreeRateTableHeight: 220, // 协议费率  表格  数据
      agreeAttrList: [{label: '长期',value: 'C'},{label: '临时',value: 'L'}], // 协议属性  下拉

      // 新增协议弹窗
      agreeDialogTitle: '', // 标题
      agreeDialog: false,
      // 客户 下拉表格
      isShow: false, // 控制下拉图标
      showPop: false, // 控制pover展示
      nameList: [], // 客户名称 列表
      nameListCopy: [], // 客户名称 列表
      agreeDialogForm: {
        conCltId: '', // 客户id
        cltName: '', //  客户
        conSigntm: '', // 签署时间
        conProperty: '', // 协议属性
        conEffsttm: '', // 协议起始时间
        conEffedtm: '', // 协议终止时间
        conContent: '', // 内容
      },
      agreeDialogRules: {
        cltName: [
          { required: true, message: '客户不能为空', trigger: 'blur' },
        ],
        conSigntm: [
          { required: true, message: '签署时间不能为空', trigger: 'blur' },
        ],
        conProperty: [
          { required: true, message: '协议属性不能为空', trigger: 'blur' },
        ],
        conEffsttm: [
          { required: true, message: '协议起始时间不能为空', trigger: 'blur' },
        ],
        conEffedtm: [
          { required: true, message: '协议终止时间不能为空', trigger: 'blur' },
        ],
        conContent: [
          { required: true, message: '内容不能为空', trigger: 'blur' },
        ],
      },

      // 新增协议费率弹窗
      agreeRateDialogTitle: '', // 标题
      agreeRateDialog: false,
      agreeRateDialogForm: {
        cchConId: '', // 传给后台的协议ID
        cchChpId: '', // 传给后台的 费率id
        agreeMent: '', // 协议
        feeNum: '', // 费目
        feeRate: '', // 费率
        cchDiscount: '', // 折扣
        cchSttm: '', // 起始时间
        cchEdtm: '', // 终止时间
        cchPayCurrency: '', // 支付币种
        cchSettlemd: '', // 支付方式
        cchRemark: '', // 备注
      },
      feeList: [], // 费目  下拉表格
      feeListCopy: [], // 费目  下拉表格
      isShow1: false, // 控制下拉图标
      showPop1: false, // 控制pover展示
      moneyCates: [{label: 'USD',value: 'USD'},{label: 'RMB',value: 'RMB'}],
      payStyles: [{label: '月结',value: 'MON'},{label: '日结',value: 'DAY'}],
    }
  },
  mounted() {
    this.searchForm.startTime = new Date((new Date()) - 7*24*3600*1000)
    this.searchForm.endTime = new Date()
    this.getData()
    this.getList()
    this.getFeeNumData()
  },
  methods:{
    // 获取  客户  表格数据
    getData() {
      getCustomerSelectService().then(res => {
        if(res.success == 1) {
          this.nameList = res.data
          this.nameListCopy = res.data
        }
      })
    },
    nowShow(){
      this.isShow = true
    },
    nowHide(){
      this.isShow = false
    },
    getCurrentRow(row) {
      this.agreeDialogForm.cltName = row.cltName
      this.agreeDialogForm.conCltId = row.cltId
      this.showPop = false
    },
    getNameData() {
      var len = this.nameListCopy.length
      var oldArr = this.nameListCopy
      var reg = new RegExp(this.agreeDialogForm.cltName)
      var newArr = []
      if(this.agreeDialogForm.cltName != '') {
        for(var i =0;i<len;i++) {
          if(this.nameListCopy[i].cltName.match(reg)) {
            newArr.push(this.nameListCopy[i])
          }
        }
      }else {
        newArr = oldArr
      }
      this.nameList = newArr
    },
    // 获取 费目  下拉表格数据
    getFeeNumData() {
      getFeeNumService().then(res => {
        if(res.success == 1) {
          this.feeList = res.data.FTKJWLHYPT
          this.feeListCopy = res.data.FTKJWLHYPT
        }
      })
    },
    nowShow1(){
      this.isShow1 = true
    },
    nowHide1(){
      this.isShow1 = false
    },
    getFeeCurrentRow(row) {
      this.agreeRateDialogForm.cchChpId = row.chpId
      this.agreeRateDialogForm.feeNum = row.chpChdName
      this.agreeRateDialogForm.feeRate = row.chpPrice
      this.showPop1 = false
    },
    getFeeData() {
      var len = this.feeListCopy.length
      var oldArr = this.feeListCopy
      var reg = new RegExp(this.agreeRateDialogForm.feeNum)
      var newArr = []
      if(this.agreeRateDialogForm.feeNum != '') {
        for(var i =0;i<len;i++) {
          if(this.feeListCopy[i].chpChdName.match(reg)) {
            newArr.push(this.feeListCopy[i])
          }
        }
      }else {
        newArr = oldArr
      }
      this.feeList = newArr
    },

    // 查询  按钮
    searchBtn() {
      this.getList()
    },
    // 获取  首页 协议 列表
    getList() {
      if(this.searchForm.startTime) {
        this.searchForm.startTime = this.resolvingDate(this.searchForm.startTime)
      }
      if(this.searchForm.endTime) {
        this.searchForm.endTime = this.resolvingDate(this.searchForm.endTime)
      }
      let needArr = Object.assign(this.searchForm,{PageIndexs: this.Pagination.currentPage},{PageSizes: this.Pagination.pageSize})
      getAgreeListService(needArr).then(res => {
        if(res.success == 1) {
          this.agreeListTableData = res.data.FTKJWLHYPT
        }
      })
    },
    timeChange(row) {
      let statu = row.conProperty
      switch (statu) {
      case 'C':
        return '长期'
      case 'L':
        return '临时'
      }
    },
    // 时间格式化
    resolvingDate(date) {
      let d = new Date(date)
      let month = (d.getMonth() + 1) < 10 ? '0'+(d.getMonth() + 1) : (d.getMonth() + 1)
      let day = d.getDate()<10 ? '0'+d.getDate() : d.getDate()

      let times = d.getFullYear() + '-' + month + '-' + day
      return times
    },
    // 新增协议  按钮
    addBtn() {
      this.agreeDialogTitle = '新增协议'
      this.agreeDialog = true
    },
    // 编辑协议  按钮
    editBtn() {
      if(Object.keys(this.agreeCurrentData).length == 0) {
        this.$alert('请选择一条数据','提示',{
          confirmButtonText: '确定'
        })
        return
      }

      this.agreeDialogForm = this.agreeCurrentData
      this.agreeDialogForm.cltName = this.agreeCurrentData.conCltName
      this.agreeDialogTitle = '编辑协议'
      this.agreeDialog = true
    },
    // 删除协议  按钮
    delBtn() {
      if(Object.keys(this.agreeCurrentData).length == 0) {
        this.$alert('请选择一条数据','提示',{
          confirmButtonText: '确定'
        })
        return
      }
      this.$confirm('您确认要删除选定的数据?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        delAgreeListService({conId: this.agreeCurrentData.conId}).then(res => {
          if(res.success == 1) {
            this.$message({
              type: 'success',
              message: '删除成功!'
            })
            this.getList()
          }
        })
      }).catch(() => {
      })
    },
    // 协议  弹窗  保存按钮
    agreeSave() {
      if(this.agreeDialogTitle == '新增协议') {
        this.$refs.agreeDialogForm.validate(valid => {
          if(valid) {
            addAgreeListService(this.agreeDialogForm).then(res => {
              if(res.success == 1) {
                this.$message({
                  type: 'success',
                  message: '添加成功'
                })
                this.agreeDialog = false
              }
            })
          }
        })
      }else if(this.agreeDialogTitle == '编辑协议') {
        this.$refs.agreeDialogForm.validate(valid => {
          if(valid) {
            let needData = Object.assign(this.agreeDialogForm,{conId: this.agreeCurrentData.conId})
            editAgreeListService(needData).then(res => {
              if(res.success == 1) {
                this.$message({
                  type: 'success',
                  message: '修改成功'
                })
                this.agreeDialog = false
              }
            })
          }
        })
      }
    },
    // 协议费率  弹窗  保存按钮
    agreeRateSave() {
      this.$refs.agreeRateDialogForm.validate(valid => {
        if(valid) {
          if(this.agreeRateDialogTitle == '新增协议费率') {
            this.agreeRateDialogForm.cchConId = this.agreeCurrentData.conId
            addAgreeRateService(this.agreeRateDialogForm).then(res => {
              if(res.success == 1) {
                this.$message({
                  type: 'success',
                  message: '新增成功'
                })
                this.agreeRateDialog = false
              }
            })
          }else if(this.agreeRateDialogTitle == '编辑协议费率') {
            editAgreeRateService(this.agreeRateDialogForm).then(res => {
              if(res.success == 1) {
                this.$message({
                  type: 'success',
                  message: '编辑成功'
                })
                this.agreeRateDialog = false
              }
            })
          }
        }
      })
    },
    // 获取  协议列表表格  当前行
    getAagreeCurrentData(row) {
      this.agreeCurrentData = row
      console.log(row)
      this.getAgreeRateData()
    },
    // 获取  协议费率列表表格  当前行
    getRateCurrentData(row) {
      this.agreeRateCurrentData = row
      console.log(row)
    },
    // 协议费率  查询
    getAgreeRateData() {
      getAgreeRateService({cchConId: this.agreeCurrentData.conId}).then(res => {
        if(res.success == 1) {
          this.agreeRateTableData = res.data.FTKJWLHYPT
        }
      })
    },
    // 新增协议费率  按钮
    addRateBtn() {
      if(Object.keys(this.agreeCurrentData).length == 0) {
        this.$alert('请选择一条协议信息','提示',{
          confirmButtonText: '确定'
        })
        return
      }
      this.agreeRateDialogForm.agreeMent = this.agreeCurrentData.conContent
      this.agreeRateDialogTitle = '新增协议费率'
      this.agreeRateDialog = true
    },
    // 编辑协议费率  按钮
    editRateBtn() {
      if(Object.keys(this.agreeRateCurrentData).length == 0) {
        this.$alert('请选择一条协议费率信息','提示',{
          confirmButtonText: '确定'
        })
        return
      }
      this.agreeRateDialogForm = this.agreeRateCurrentData
      this.agreeRateDialogForm.agreeMent = this.agreeCurrentData.conContent
      this.agreeRateDialogForm.cchConId = this.agreeCurrentData.conId
      this.agreeRateDialogForm.cchChpId = this.agreeRateCurrentData.cchChpId
      this.agreeRateDialogForm.feeNum = this.agreeRateCurrentData.chdCnname
      this.agreeRateDialogForm.feeRate = this.agreeRateCurrentData.chpPrice
      this.agreeRateDialogTitle = '编辑协议费率'
      this.agreeRateDialog = true
    },
    // 删除协议费率  按钮
    delRateBtn() {
      if(Object.keys(this.agreeRateCurrentData).length == 0) {
        this.$alert('请选择一条数据','提示',{
          confirmButtonText: '确定'
        })
        return
      }
      this.$confirm('您确认要删除选定的数据?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        delAgreeRateService({cchId: this.agreeRateCurrentData.cchId}).then(res => {
          if(res.success == 1) {
            this.$message({
              type: 'success',
              message: '删除成功!'
            })
            this.getAgreeRateData()
          }
        })
      }).catch(() => {
      })
    },
    // 协议  弹窗  关闭事件
    agreeDialogClose() {
      this.agreeDialogForm.cltName = ''
      this.agreeDialogForm.conSigntm = ''
      this.agreeDialogForm.conProperty = ''
      this.agreeDialogForm.conEffsttm = ''
      this.agreeDialogForm.conEffedtm = ''
      this.agreeDialogForm.conContent = ''
      this.agreeCurrentData = ''
      this.getList()
    },
    // 协议费率  弹窗  关闭事件
    agreeRateDialogClose() {
      this.agreeRateDialogForm.feeNum = ''
      this.agreeRateDialogForm.feeRate = ''
      this.agreeRateDialogForm.cchRemark = ''
      this.agreeRateDialogForm.cchDiscount = ''
      this.agreeRateDialogForm.cchSttm = ''
      this.agreeRateDialogForm.cchEdtm = ''
      this.agreeRateDialogForm.cchPayCurrency = ''
      this.agreeRateDialogForm.cchSettlemd = ''
      this.agreeRateCurrentData = ''
      this.getAgreeRateData()
    },
    // 格式化表格数据
    changePayStyle(row) {
      let statu = row.cchSettlemd
      switch (statu) {
      case 'MON':
        return '月结'
      case 'DAY':
        return '日结'
      }
    }
  },
}
</script>

<style lang="scss" scoped>
.agreeManage{
  .agreeSearch {
    padding: 10px 0 0 10px;
  }
}
.agreeTopTitle {
  font-weight: bold;
  font-size: 14px;
  padding-left: 10px;
}
.agreeTopBtnBox {
  padding: 10px;
}
::v-deep .agreeDialogBox {
  .el-input__inner {
    width: 193px;
  }
}
::v-deep .agreeRateDialogBox {
  .el-input__inner {
    width: 193px;
  }
}
</style>

